/* 
 * File:   SceneManager.cpp
 * Author: Pie
 * 
 * Created on April 25, 2011, 3:13 PM
 */
#include <fstream>

#include "SceneManager.h"

SceneManager::SceneManager(TextureManager* texture) {
    _texture = texture;
    _root = new ObjectModel(0);
}

SceneManager::~SceneManager() {
    delete _root;
}

void SceneManager::import(const string& name, const string& file) {
    const aiScene* scene = _importer.ReadFile(file, aiProcessPreset_TargetRealtime_Quality);
//    const aiScene* scene = _importer.ReadFile(file,
//            aiProcess_JoinIdenticalVertices |
//            aiProcess_Triangulate |
//            aiProcess_GenSmoothNormals |
//            aiProcess_SplitLargeMeshes |
//            aiProcess_ImproveCacheLocality |
//            aiProcess_RemoveRedundantMaterials |
//            aiProcess_FixInfacingNormals |
//            aiProcess_OptimizeMeshes);
    if (!scene) {
        return ;
    }
    ObjectScene* obj_scene = new ObjectScene(scene);    
    _importer.FreeScene();
    _root->add_child(new ObjectModel(obj_scene));
}

void SceneManager::traverse() {

}

void SceneManager::draw() {
    _root->draw();
}